<?php
namespace App\Model;

use PhalApi\Model\NotORMModel as NotORM;

class Banner extends NotORM {

    //设置表名
    protected function getTableName($id) {
        return 'ad';
    }

    // 获取全部banner
    public function getAllBanner() {
        return $this->getORM()
            ->select('ad_id,ad_name,ad_link,ad_code,click_count')
            ->where( 'pid', 1 )
            ->order('orderby')
            ->fetchAll();
    }

    // 获取全部活动
    public function getAllAction() {
        return $this->getORM()
            ->select('ad_id,ad_name,ad_link,ad_code,click_count')
            ->where( 'pid', 2 )
            ->order('orderby')
            ->fetchAll();
    }

    // 获取分类
    public function getAllCategory() {
        return $this->getORM()
            ->select('ad_id,ad_name,ad_link,ad_code,click_count')
            ->where( 'pid', 3 )
            ->order('orderby')
            ->fetchAll();
    }
//    public function getListTotal($state) {
//        $total = $this->getORM()
//            ->where('state', $state)
//            ->count('id');
//
//        return intval($total);
//    }
}
